package com.collect.tanzania.zhiUtils;

import android.util.Log;

public class ShortTest {

    //源数据1
    public static short[] aes_key =
            {
                    0x96, 0xB6, 0x71, 0x5E, 0xF5, 0x0F, 0xA4, 0x55,
                    0x7F, 0x6C, 0xF9, 0x77, 0x17, 0x8E, 0x86, 0xC9
            };

    //源数据2
    // 11 c5 00 74 0b e4 4d 4e
    // e5 bd ae d0 3c e7 6f ff
    public static short[] aes_iv =
            {
                    0x11, 0xC5, 0x00, 0x74, 0x0B, 0xE4, 0x4D, 0x4E,
                    0xE5, 0xBD, 0xAE, 0xD0, 0x3C, 0xE7, 0x6F, 0xFF
            };


    //      C           bits        bytes     Java
    //  uint8_t         8           1         short
    //  uint16_t        16          2         int
    //  uint32_t        32          4         long


    /**
     * short数组转16进制字符串
     */
    public static String shortToHexString(short[] shorts) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            for (short a : shorts) {
                String aShort = Integer.toHexString(a);
                if (aShort.length() < 2) {
                    stringBuilder.append("0");
                }
                stringBuilder.append(aShort);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        Log.d(ShortTest.class.getSimpleName(), "shortStreamToString: " + stringBuilder.toString().toUpperCase());

        return stringBuilder.toString().toUpperCase();
    }

}
